#!/usr/bin/env sh
make || exit

#requires: all_tests

of=run.log.1
if ! ./test -d test_dir > $of 2>&1
then
    cat $of
    exit 1
fi

of=run.log.2
if ./test -d not_here > $of 2>&1
then
    echo "Expected error as not_here is not here"
    exit 1
else
    if ! grep -i not $of|grep -i dir | grep not_here > /dev/null 2>&1
    then
        echo "Expected error message containing that not_here is not a directory"
        exit 1
    fi
fi

of=run.log.3
if ./test -d runtest > $of 2>&1
then
    echo "Expected error as runtest is not a directory"
    exit 1
else
    if ! grep -i not $of|grep -i dir | grep runtest > /dev/null 2>&1
    then
        echo "Expected error message containing that runtest is not a directory"
        exit 1
    fi
fi


echo "Test Succesfull"
